<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@page import="com.tjsinfo.tjsoa.mail.vo.TjsDraft"%>
<%@page import="com.tjsinfo.tjsoa.mail.vo.TjsDraftReceived"%>
<%@page import="com.tjsinfo.tjsoa.mail.vo.TjsDraftAnnex"%>
<%@page import="com.tjsinfo.tjsoa.common.ToolKit"%>
<%@page import="com.tjsinfo.tjsoa.common.SessionUser"%>
<%@page import="com.tjsinfo.tjsoa.system.vo.User"%>
<%
String path = request.getContextPath();
//String treePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+"/RQOAtree/";
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String nowSQL = ToolKit.getProperties("com/tjsinfo/tjsoa/mail/properties/systemResource.properties", this).getProperty("nowSQL");
%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<base href="<%=basePath%>" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>粮油集团办公自动化协作平台</title>
	<link href="<%=basePath %>style/txlz7.css" rel="stylesheet" type="text/css" />
	<link href="<%=basePath%>style/red.css" rel="stylesheet" type="text/css" />
	<!-- 多系统树 开始 -->
	<link href="<%=basePath %>ajaxFramework/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
		<script type="text/javascript" src="<%=basePath%>js/ie.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/png.js"></script>
	<style >
		#uploadList li {
			float:  left;
			margin-right:  10px;
			width: 100%
		}
		.silk-del{
        background-image:url(<%=basePath %>ajaxFramework/ext-2.1/shared/icons/fam/delete.gif) !important;
	</style>
	<link href="<%=basePath %>ajaxFramework/ext/resources/css/ext-all.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-base.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-all.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext-2.1/init.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/ux/ux-all.js"></script>	
<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/jQuery/jquery.form.js"></script>
<script type="text/javascript" src="<%=basePath %>ajaxFramework/ext/extension/window/window.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/global/validator.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/global/pageControl.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/fileUpload/ajaxfileupload.js"></script>
	<script type="text/javascript" src="<%=basePath %>js/common/fileUpload/ajaxFileZx.js"></script>
	<!-- <script type="text/javascript" src="<%=basePath %>js/common/system/singleuserinfocheckedtree.js"></script> -->
	<script type="text/javascript" src="<%=basePath %>js/common/system/selectusertreecheck.js"></script>
	<script type="text/javascript" src="<%=basePath%>FCKeditor/fckeditor.js"></script>
	<script type="text/javascript" src="<%=basePath %>email/js/email.js"></script>
	<%--
	<script type="text/javascript">
	function peopleTree(){
		var win = userinfochecktree(<%=nowSQL %>,<%=SessionUser.getUserId(request) %>);
		win.show();
		win.on("winsubmint",function(data){
			document.getElementById('jubaorename').value = data.usernametext;
			document.getElementById('jubaorenid').value = data.usertext;
			win.hide();
			if(document.getElementById('writeName').value!=''){
				document.getElementById('jubaorename').value += ','+document.getElementById('writeName').value;
			}
		});
	}
	</script>--%>
	<!-- 结束 -->
	<script type="text/javascript">
	//初始化方法
	function init(){
	  initselectusertreecheck();	  
	}
	//定义初始化程序
	window.onload = init;
	</script>
	<script type="text/javascript">
	var lianxiangvalue = '';
	var lianxiangzong = '';
	//var sendusers='';
	var shiji = '';
	
	function windowonload(){			
		//document.getElementById("rightindex").style.height = document.body.clientHeight;
		//document.getElementById("p_03").style.height = 390;
		//document.getElementById("p_80").style.width = document.body.clientWidth-132;
		//document.getElementById("tdindex").style.height = document.body.clientHeight-90;
		//document.getElementById("divindex").style.height = document.body.clientHeight-165;
	}
		function submitform()
		{
			var uuuuuuu = document.getElementById('uuuuuuu').value;
			var contest= document.getElementById('contest').value;
			var title = document.getElementById('title').value;
			document.getElementById('lianxiangzong').value = Ext.get("_combobox").dom.value;
			//alert(uuuuuuu);
			//for(var a = 0; a<length; a++)
			//{
			//	var check1 = checkbox2[a].value;
			//	sendusers += check1+",";	
			//}
			//if(uuuuuuu == ''){
				//document.getElementById('uuuuuuu').value=Ext.get("_combobox").dom.value;
			//}else{
				//document.getElementById('uuuuuuu').value = uuuuuuu.substring(0,uuuuuuu.length-1)+','+Ext.get("_combobox").dom.value;
			//}
			if(title == ''){
				Ext.MessageBox.alert('提示框','<nobr>请输入主题<nobr>');
				return;
			}else{
				document.getElementById('title').value = title.substring(0,title.length);
				document.form1.submit();
			}
		}	
		function back()
		{
			history.back(-1);
		}
		function savedraf()
		{	
			
			var uuuuuuu = document.getElementById('uuuuuuu').value;
			var contest= document.getElementById('contest').value;
			var title = document.getElementById('title').value;	
			//alert(uuuuuuu);
			//alert(contest);
			//alert(title);
			//$("form[name=form1]").attr("action",url);
			//$("form[name=form1]").submit();
			document.form1.action="<%=basePath%>tjsinfo/tjsoa/mail/saveDraf.do";
			//alert(uuuuuuu);
			//alert(contest);
			//alert(title);
			document.form1.submit();
		}
		function clearinputtwo(_name,_id){
			$('#'+_name).attr('value','');
			$('#'+_id).attr('value','');
			$('#jubaorenInput').attr('value','');
			$('#writeName').attr('value','');
		}
		function changdiv(){
			//mail_right.scrollIntoView();
			// mail_right.scrollTop=mail_right.scrollHeight
		}
		
		//window.onload = function(){
			//initselectusercheck();
			//document.getElementById("mail_right").style.height = document.body.clientHeight-60;
		//}
		
	Ext.onReady(function(){
        //Ext.QuickTips.init();
        
        // 格式化数据，数据也可采用json数据
		var ds = new Ext.data.JsonStore({
	 		fields:['userId','userName'],
	 		url:'<%=basePath %>tjsinfo/tjsoa/system/selectUserByName.do',
 			root: 'root'
	 	});
		/*function delFile(id,name){
			document.getElementById('deletefujian').value += id+',';
			isDelete(name);
		}*/
		 var storeList = new Ext.form.ComboBox({        
	            store: ds,
	            valueField:'userId',     // option的值
	            displayField: 'userName',//option的显示文本
	            triggerAction: 'all',
	            emptyText:'请选择',
	            mode: 'local',
	            selectOnFocus:true,
	            renderTo:'show',
	            width:235,
	            id:'_combobox',
	           hideTrigger:true
	        });
	        
	        //取得option值函数
	        function getVal(){
	            //var val = storeList.getValue();//取得option值
	           	lianxiangzong += Ext.get("_combobox").dom.value;
	           	Ext.get("_combobox").dom.value = lianxiangzong;
	           	//alert(storeList.value);
	           	//shiji += storeList.value;
	        }

	        storeList.on('select', getVal);//当选择时触发该函数
	        
	        function lianxiang(){
	        	if(lianxiangvalue!=Ext.get("_combobox").dom.value){
		        	ds.removeAll();
		            ds.proxy = new Ext.data.HttpProxy({url:encodeURI('<%=basePath %>tjsinfo/tjsoa/system/selectUserByName.do')});
		           	ds.reload({params:{userName:Ext.get("_combobox").dom.value}}); 
	           		lianxiangvalue = Ext.get("_combobox").dom.value;
	        	}
	        }
	        
	        storeList.on('beforequery', lianxiang);//当选择时触发该函数
		});
			</script>
	<script language="javascript">
	if(document.addEventListener){//如果是Firefox
		document.addEventListener("onkeydown",fireFoxHandler, true);
	}else{
		document.attachEvent("onkeydown",ieHandler);
	}
	function fireFoxHandler(evt){
			//alert("firefox");
			if(evt.keyCode==13){
				submitform();
			}
		}
	function ieHandler(evt){
		//alert("IE");
		if(evt.keyCode==8){
			if(document.activeElement.id=='_combobox'){
				var _title = Ext.get("_combobox").dom.value;
				if(_title!=null && _title!=''){
					var a = _title.substring(_title.length-1,_title.length);
					if(a==';'){
						_title = _title.substring(0,_title.length-1);
						if(_title.indexOf(';')!=-1){
							Ext.get("_combobox").dom.value = _title.substring(0,_title.lastIndexOf(';')+2);
							lianxiangzong = Ext.get("_combobox").dom.value;
							
							shiji = shiji.substring(0,shiji.length-1);
							shiji = shiji.substring(0,shiji.lastIndexOf('@')+1);
						}else{
							Ext.get("_combobox").dom.value = '';
							lianxiangzong = '';
						}
					}
				}
			}
		}
	}
			
	</script>
	<!-- 执行上传文件操作的函数 -->
	<script type="text/javascript">
		var deleteFile;
		var alreadyUploadFile='';
		var uploadUrl='<%=basePath %>tjsinfo/tjsoa/system/ajaxFileUpload.do?method=uploader';
		var deteleFileUrl='<%=basePath %>tjsinfo/tjsoa/system/ajaxFileUpload.do?method=deleted';
	</script>
	<script type="text/javascript" src="<%=basePath %>email/js/writemailfrom.js"></script>
</head>
  
<body style="height:595px;">
<%
     TjsDraft tjsDraft = (TjsDraft)request.getAttribute("draft");
     Iterator iterator =	tjsDraft.getTjsDraftReceiveds().iterator();
     Iterator iterator2 =	tjsDraft.getTjsDraftReceiveds().iterator();
     String zhusongstr = "";
     String chaosongstr = "";
     String zhusongid = "";
     String chaosongid = "";
     while(iterator.hasNext())
     {
    	 TjsDraftReceived tjsDraftReceived = (TjsDraftReceived)iterator.next();
    	 if(tjsDraftReceived.getRecNature() == 1)
    	 {
    		 zhusongstr +=  tjsDraftReceived.getTjsUser().getUserName()+",";
    		 zhusongid +=   tjsDraftReceived.getTjsUser().getUserId()+",";
    	 }
    	 
     }
     while(iterator2.hasNext())
     {
    	 TjsDraftReceived tjsDraftReceived = (TjsDraftReceived)iterator2.next();
    	 if(tjsDraftReceived.getRecNature() == 2)
    	 {
    		 chaosongstr +=  tjsDraftReceived.getTjsUser().getUserName()+",";
    		 chaosongid +=   tjsDraftReceived.getTjsUser().getUserId()+",";
    	 }
     }
%>
  <div id="rightindex" style="height:595px;">
		<div id="mailcontent" > 
			<div id="mail_title">
                <ul></ul>
            </div>
            <div id="mail_left" style="height: 94%">
                <div class="p_01">
                    <a  href="<%=basePath %>tjsinfo/tjsoa/mail/emailReceivedList.do" class="a1"><img src="<%=basePath %>images/mailicon03.gif" /></a><a href="<%=basePath %>tjsinfo/tjsoa/mail/writemailfrom.do" class="a2"><img src="<%=basePath %>images/mailicon04.gif" /></a>
                </div>
              <h1>
                </h1>
                <div class="p_02">
                <ul>
                    <li class="l_01"><a href="<%=basePath %>tjsinfo/tjsoa/mail/emailReceivedList.do">收件箱</a></li>
                    <li class="l_05"><a href="<%=basePath %>tjsinfo/tjsoa/mail/emailWeiReadReceived.do">未读邮件</a></li>
                    <li class="l_02"><a href="<%=basePath %>tjsinfo/tjsoa/mail/emailDraftList.do">草稿箱</a></li>
                    <li class="l_03"><a href="<%=basePath %>tjsinfo/tjsoa/mail/selectEmaiList.do">已发送</a></li>
                    <li class="l_04"><a href="<%=basePath %>tjsinfo/tjsoa/mail/deleteEmaiList.do">已删除</a></li>
                    <c:forEach var="fold" items="${foldlist}">
                    <li class="l_05"><a href="<%=basePath%>tjsinfo/tjsoa/mail/selectfoldemail.do?id=${fold.folderId}">${fold.folderName}</a></li>
                    </c:forEach>            
                </ul>
                </div>
                <div class="p_03">
                    <div class="s01">
                      <table width="100%" border="0" cellspacing="0">
                        <tr>
                          <td height="25"><strong></strong></td>
                        </tr>
                        <tr>
                          <td height="25"></td>
                        </tr>
                        <tr>
                          <td height="25"></td>
                        </tr>
                      </table>
                    </div>
                </div>
            </div>
	<form name="form1" action="<%=basePath %>tjsinfo/tjsoa/mail/writemail.do" method="post" id="form1" > 
            <div id="mail_right" style="height: 98%">
             <div class="p_11" style="width:99%">
                <ul>
                    <li class="s01"><a href="javascript:submitform()">发送</a></li>
                    <li class="s04"><a href="javascript:back()">取消</a></li>                        
                </ul>
	          </div>
             <div class="p_80"style="height: 99%">
              <table width="98%" border="0" cellspacing="0" align="left">
                <tr>
                  <td width="5px;">
                  	<!-- <a href="javascript:selectusercheckwinshow('jubaorenid','jubaorename','node')" > -->
                  	<a>
                  		<img src="<%=basePath %>images/m_icon118.gif" width="67" height="22" />
                  	</a>
                  </td>
                  <td  width="550px">
                 	 <table cellpadding="0" cellspacing="0">
                 	 	<tr>
                  		<td width="250px" align="left"><div id="show" style="width: 200px"></div></td>
                  		<td><input name="uuuuuuu" id="uuuuuuu" size="30" style="height: 17px;width: 300px;margin-bottom: 0px" readonly="readonly">
                  		<input type="hidden" id="sendusers" name="sendusers"/></td>
                  		</tr>
                  	</table>
        		</td>
        		<td>
                  	<a href="javascript:void(0)" onclick="selectusertreecheckwinshow('sendusers','uuuuuuu','node')">菜单树选择</a>&nbsp;&nbsp;
                  	<a href="javascript:clearinputtwo('uuuuuuu','sendusers')">清空菜单树</a> 
                  </td>
                </tr>
                <tr>
                  <td width="5px;">
                  	<img src="<%=basePath %>images/m_icon211.gif" width="67" height="22" />
                  </td>
                  <td colspan="2">
                  	<input name="title" id="title" size="30" maxlength="20" style="height:17px;width:500px; margin-bottom:0px" value="${draft.draftTitle }" />
                  </td>
                </tr>
                <tr>
					<td width="5px;">
	                  	<img src="<%=basePath %>images/m_icon212.gif" width="67" height="21" />
	                </td>
	                <td width="250px" colspan="2">
	               	 <table cellpadding="0" cellspacing="0">
	                	<tr><td align="left">
	                	<span><input type="file" UNSELECTABLE="on"  name="uploadFile" id="uploadFile" size="34" class="textinput" /></span>
	                	<div class="sc_listLong">
	                		<ul id="uploadList" >
	                		<%
		                		if(tjsDraft.getTjsDraftAnnexes().size()>0){
	                				Iterator iterator4  = tjsDraft.getTjsDraftAnnexes().iterator();
	                				while(iterator4.hasNext()){
		                				TjsDraftAnnex tjsDraftAnnex = (TjsDraftAnnex)iterator4.next();
		                	%>
		                		<li id='<%=tjsDraftAnnex.getAnnexName().substring(0,tjsDraftAnnex.getAnnexName().indexOf(".")) %>'><%=tjsDraftAnnex.getAnnexZhenName()%><span onclick='delFile("<%=tjsDraftAnnex.getAnnexId() %>","<%=tjsDraftAnnex.getAnnexName() %>");' style='color: #999999;cursor:hand'>删除</span></li>
		                	<% 				
		                			}
		                		}
		                	%>
	                		</ul>
	                	</div>
	                	</td>
	                	<td>
	                	<span><a style="cursor: hand" onclick="ajaxFileUpload();"><img src="<%=basePath %>images/scicon.gif" style="margin-bottom:2px"/></a></span>
	                	</td>
	                	</tr></table>
	                </td>
                </tr>
                <tr>
                  <td colspan="3"><textarea name="contest" id="contest"
						style="width: 100%; height: 595px;">${draft.draftValue }</textarea>
						<script type="text/javascript">
						var oFCKeditor = new FCKeditor('contest') ;
						oFCKeditor.BasePath = 'FCKeditor/' ;
						oFCKeditor.ToolbarSet = 'Zoa' ;
						oFCKeditor.Width = '98%' ;
						oFCKeditor.Height = '400px' ;
						oFCKeditor.Value = '' ;
						oFCKeditor.ReplaceTextarea(); 
						//oFCKeditor.Create() ;
                        </script>
				  </td>
                </tr>
              </table>
            </div> 
            </div>
            <input  type="hidden" name="panduan" id="panduan"/>
            <input  type="hidden" name="sendInput" id="jubaorenInput"/>
            <input  type="hidden" name="writeName" id="writeName"/>
			<input  type="hidden" name="node" id="node"/>
			<input id="basePath" value="<%=basePath%>" type="hidden"/>
			
			<input  type="hidden" name="sendid" id="jubaorenid" value="<%=zhusongid %>"/>
			<input  type="hidden" name="chaosongid" id="chaosongid" value="<%=chaosongid %>"/>
			<input  type="hidden" name="misongid" id="misongid"/>
			<input  type="hidden" name="drafid" value="${draft.draftId}"/>
			<input  type="hidden" name="fujianname1" id="fujianname1"/>
			<input  type="hidden" name="deletefujian" id="deletefujian" value=""/>
			<input  type="hidden" name="lianxiangzong" id="lianxiangzong"/>
			
            <div id="files" style="display: none;">
            	<%
		        if(tjsDraft.getTjsDraftAnnexes().size()>0){
		        	Iterator iterator4  = tjsDraft.getTjsDraftAnnexes().iterator();
		        	while(iterator4.hasNext()){
						TjsDraftAnnex tjsDraftAnnex = (TjsDraftAnnex)iterator4.next();
                	%>
                		<input type='hidden' name='fiid<%=tjsDraftAnnex.getAnnexName().substring(0,tjsDraftAnnex.getAnnexName().indexOf(".")) %>' id='fiid<%=tjsDraftAnnex.getAnnexName().substring(0,tjsDraftAnnex.getAnnexName().indexOf(".")) %>' value='<%=tjsDraftAnnex.getAnnexName() %>'/>
                		<input type='hidden' name='fiNa<%=tjsDraftAnnex.getAnnexName().substring(0,tjsDraftAnnex.getAnnexName().indexOf(".")) %>' id='fiNa<%=tjsDraftAnnex.getAnnexName().substring(0,tjsDraftAnnex.getAnnexName().indexOf(".")) %>' value='<%=tjsDraftAnnex.getAnnexZhenName() %>'/>
                	<%
                	}
                }
                %>
            </div>
		</form>
   </div>
</div>
<form action="" name="form2" method="post">
</form>
  </body>
</html>
